|
|
|
|
|
|
|
should treat the coding process like you're peeling an orange. Start by coding the main form of your application with the menu and button bar in place (see Figure 1.3). When you code your application, start with what the user will see when it's started. |
|
|
|
|
|
|
|
|
Figure 1.3.
Main form of a sample application showing
the skeleton of the user interface. |
|
|
|
|
|
|
|
|
At this point, if you selected any menu or button options, nothing much would happen because you haven't written any code related to those options. Writing code for the computer isn't as simple as writing a letter. The code placed in a Visual Basic application is organized in a hierarchical fashion. An application generally consists of one or more modules, including form modules, one for each form in the application; standard modules for shared code; and possibly class modules. Determining which procedures belong in which module depends somewhat on the type of application you're creating. |
|
|
|
|
|
|
|
|
There are certain ways or conventions for formatting and labeling everything in program code. Coding conventions is an attempt to standardize the structure and coding style of any application so that you and more importantly others can easily read, understand, and maintain the code. Because most applications aren't as simple as the Hello World example most books use to teach programming, the organization or structure of your application code becomes very important. Depending on what a section of code does and where it's used, you would place it in different areas of your application. Code is placed in three areas: |
|
|
|
|
|
|
|
|
Event procedures are subprograms coded to execute in response to specific events in your application. |
|
|
|
|
|
|
|
|
Standard code modules are subprograms not related to a specific form or control that might be used by objects in different forms. |
|
|
|
|
|
|
|
|
Class modules contain code and data. |
|
|
|
|
|
|
|
|
By structuring your code properly and following good coding conventions, your source code would be more precise, readable, unambiguous, and as intuitive as possible. |
|
|
|
|
|